<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../layui/css/layui.css" />
    <style>
        .layui-input {
            width: 220px;
        }
        .layui-form-item{
            margin-top: 5px;
            padding-bottom: 15px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">原属地区</label>
        <div class="layui-input-block">
            <input type="text" name="harea" required  lay-verify="required" placeholder="请输入原属地区" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属小区</label>
        <div class="layui-input-block">
            <input type="text" name="hestate" required  lay-verify="required" placeholder="请输入所属小区" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">单元号</label>
        <div class="layui-input-block">
            <input type="text" name="hunitNumber" required  lay-verify="required" placeholder="请输入单元号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属楼层</label>
        <div class="layui-input-block">
            <input type="text" name="hfloor" required  lay-verify="required" placeholder="请输入所属楼层" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房间号</label>
        <div class="layui-input-block">
            <input type="text" name="hroomNo" required  lay-verify="required" placeholder="请输入房间号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">面积</label>
        <div class="layui-input-block">
            <input type="text" name="hacreage" required  lay-verify="required" placeholder="请输入面积" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">朝向</label>
        <div class="layui-input-block">
            <input type="text" name="hdirection" required  lay-verify="required" placeholder="请输入朝向" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">装修</label>
        <div class="layui-input-block">
            <input type="text" name="hfitment" required  lay-verify="required" placeholder="请输入装修" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否双气</label>
        <div class="layui-input-block">
            <select name="hisDoubleAir" lay-verify="required">
                <option value="0">是</option>
                <option value="1">否</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">限住人数</label>
        <div class="layui-input-block">
            <input type="text" name="hlimit" required  lay-verify="required" placeholder="请输入限住人数" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">配套设施</label>
        <div class="layui-input-block">
            <input type="text" name="hfacility" required  lay-verify="required" placeholder="请输入配套设施" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出租价格</label>
        <div class="layui-input-block">
            <input type="text" name="hprice" required  lay-verify="required" placeholder="请输入出租价格" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否出租</label>
        <div class="layui-input-block">
            <select name="hstatus" lay-verify="required">
                <option value="1">未出租</option>
                <option value="2">已出租</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房屋地址</label>
        <div class="layui-input-block">
            <input type="text" name="haddress" required  lay-verify="required" placeholder="请输入房屋地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">添加时间</label>
        <div class="layui-input-block">
            <input name="haddtime" type="text" class="layui-input" id="test1">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="btn1" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="../../layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        var $=layui.$;
        //监听提交
        form.on('submit(formDemo)', function(data){
            //通过ajax提交后台
            $.ajax({
                type:"post",
                url:"/HouseServlet?method=insert",
                data:$('form').serialize(),
                //提交成功获取返回的数据
                dataType:'text',
                success:function(data){
                    if(data.code==0) {
                        layer.msg('新增成功')
                    }
                },
                error:function () {
                    layer.msg('新增失败')
                }
            })
            var index=parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
        laydate.render({
            elem: '#test1'    //指定元素test1
        });
    });
</script>
</body>
</html>